# 1、打开Chrome，打开百度首页
# 2、搜索框输入python自动化测试，点击百度一下
# 3、等待2秒
# 4、获取页面标题，并打印出来
# 5、检查’python’关键字是否在标题中
# 6、关闭Chrome浏览器
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
#TODO 第一遍
'''
class TastCase1:
    def __init__(self):
        self.driver=webdriver.Chrome()
    # 1、打开Chrome，打开百度首页
    def get_baidu(self):
        self.driver.get('https://www.baidu.com')
    #输入关键字点击搜索
        kw=self.driver.find_element(By.ID,'kw')
        kw.send_keys('源码时代')
        su=self.driver.find_element(By.ID,'su')
        su.click()
        time.sleep(20)
        print(self.driver.title)
    #判断
        if '源码' in self.driver.title:
            print('ok')
        else:
            print('no')
    #退出浏览器
    def quit(self,seconds=2):
        time.sleep(seconds)
        self.driver.quit()
if __name__ == '__main__':
    case=TastCase1()
    case.get_baidu()
    case.quit()
'''

#TODO 第二遍
'''
class TastCase2:
    def __init__(self):
        self.driver=webdriver.Chrome()
    def get_baidu(self):
        self.driver.get('https://www.baidu.com')
        kw=self.driver.find_element(By.ID,'kw')
        kw.send_keys('天气预报')
        su=self.driver.find_element(By.ID,'su')
        su.click()
        time.sleep(20)
        print(self.driver.title)
        if '天气' in self.driver.title:
            print('ok')
        else:
            print('no')
    def quit(self,seconds=2):
        time.sleep(seconds)
        self.driver.quit()
if __name__ == '__main__':
    case=TastCase2()
    case.get_baidu()
    case.quit()
'''

#TODO 第三遍
import time

from selenium import webdriver
from selenium.webdriver.common.by import By
class TestCase:
    def __init__(self):
        self.driver=webdriver.Chrome()
    def get_360(self):
        self.driver.get('http:www.so.com')
        self.driver.find_element(By.ID,'input').send_keys('微信')
        self.driver.find_element(By.ID,'search-button').click()
        time.sleep(2)
    def quit(self,seconds=3):
        time.sleep(seconds)
        self.driver.quit()
if __name__ == '__main__':
    t1=TestCase()
    t1.get_360()
    t1.quit()